package com.vint.basic;

/*
 *
 */

public class Longest {
	/*
	 * 最大子序列
	 */
	public static int MaxSubSequences(int[] a) {
		int maxSum = Integer.MIN_VALUE;
		int tmp = maxSum;
		for(int i : a) {
			if(i + tmp > i) {
				tmp += i;
			} else {
				tmp = i;
			}
			if(tmp > maxSum){
				maxSum = tmp;
			}
		}
		return maxSum;
	}

	/*
	 *最长递增子序列
	 */
	public static int LongestIncreaseSequences(int[] a) {
		return 0;

	}
	public static void main(String[] args) {
		int[] a = {1,2,-2,4,5};
		System.out.println(MaxSubSequences(a));
	}
}
